//
//  ZH_MineOrderTopTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/22.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_MineOrderTopTableViewCell.h"
@interface ZH_MineOrderTopTableViewCell()
@property (nonatomic,weak)UIImageView *iconImages;
@property (nonatomic,weak)UILabel *nameLabel;
@property (nonatomic,weak)UILabel *stateLabel;
@end
@implementation ZH_MineOrderTopTableViewCell

///创建
+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_MineOrderTopTableViewCell";
    ZH_MineOrderTopTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_MineOrderTopTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
///初始化
-(void)initDefault
{
    [self unShowClickEffect];
    self.bottomShortLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.iconImages mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(12));
        make.left.equalTo(self.contentView).offset(FITSCALE(11));
        make.centerY.equalTo(self.contentView);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);;
        make.left.equalTo(self.iconImages.mas_right).offset(FITSCALE(7));
    }];
    [self.stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(-11);
    }];
}
- (void)updateUI:(NSDictionary *)data{
    if (data) {
        self.iconImages.image = [UIImage imageNamed:@"icon_teachername"];
        self.nameLabel.text = [NSString stringWithFormat:@"%@",data[@"teacher_name"]];
        NSString *string = [NSString stringWithFormat:@"%@",data[@"status"]];
        if ([string isEqualToString:@"1"]) {
            self.stateLabel.text = @"代付款";
        }
        else if ([string isEqualToString:@"2"]){
            self.stateLabel.text = @"代上课";
        }
        else if ([string isEqualToString:@"3"]){
            self.stateLabel.text = @"代上课";
        }
    }
}
#pragma mark - getter,setter
- (UIImageView *)iconImages{
    if (!_iconImages) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_market"];
        [self.contentView addSubview:_iconImages = image];
    }
    return _iconImages;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        UILabel *label = [UILabel createLabelWithText:@"店铺名称..." font:kFontSize_28];
        [self.contentView addSubview:_nameLabel = label];
    }
    return _nameLabel;
}
- (UILabel *)stateLabel{
    if (!_stateLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.text = @"代付款";
        label.font = [UIFont boldSystemFontOfSize:12];
        label.textColor = [UIColor colorWithHexString:@"#00C9AE"];
        [self.contentView addSubview:_stateLabel = label];
    }
    return _stateLabel;
}

@end
